﻿using GalaSoft.MvvmLight;
using System.Collections.ObjectModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model.Main;
using Model.Login;
using IService.Main;
using System.Windows.Input;
using GalaSoft.MvvmLight.CommandWpf;

namespace ViewModel.Main
{
    public class MainViewModel:ViewModelBase
    {
        public MainViewModel(IMainService service)
        {
            _service = service;
            InitCommand = new RelayCommand(Init);
        }
        #region 服务
        IMainService _service;
        #endregion
        #region 属性
        private ObservableCollection<FriendGroup> _friends;

        public ObservableCollection<FriendGroup> Friends
        {
            get { return _friends; }
            set
            {
                _friends = value;
                RaisePropertyChanged(() => Friends);
            }
        }

        private UserInfo _uesr;

        public UserInfo User
        {
            get { return _uesr; }
            set
            {
                _uesr = value;
                RaisePropertyChanged(()=>User);
            }
        }
        #endregion
        #region 命令
        public ICommand InitCommand { get; set; }
        private void Init()
        {
            User = _service.GetUserInfo(null);
            Friends =_service.GetFriends(null);
        }
        #endregion
    }
}
